﻿package com.dykj.apps.web.sysmanager.action;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.dykj.apps.web.core.BaseAction;
import com.dykj.apps.web.sysmanager.service.ISysAclBS;
import com.dykj.platform.framework.exception.ApplicationException;
/**
 * 功能点授权
 * @author zhaolp
 *
 */
public class SysAclAction extends BaseAction{
	private List roleList = new ArrayList();
	private ISysAclBS bs;
	private String roleid;
	private String acl;
	private String[] functionid;

	/**
	 * 初始化添加用户
	 * @return
	 */
	public String initSysAcl()throws ApplicationException{
		return "forwardinitSysAclMain";
	}
	/**
	 * 查询角色
	 * @return
	 * @throws ApplicationException
	 */
	public String findAllRole()throws ApplicationException{
		Map info = (Map)this.getSession().getAttribute("userinfo");
		String username=info.get("username").toString();
		roleList = bs.findAllRole(username);
		return "forwardinitSysAclRole";
	}
	/**
	 * 查询授权列表
	 * @return
	 * @throws ApplicationException
	 */
	public String findFunctionAcl()throws ApplicationException{
		Map info = (Map)this.getSession().getAttribute("userinfo");
		String type = info.get("type").toString();	
		String croleid=info.get("roleid").toString();
		if("0".equals(type)){
			croleid=null;
		}
		acl=bs.findFunctionJSON(roleid,croleid);
		return "forwardinitSysFunction";
	}
	/**
	 * 保存授权列表
	 * @return
	 * @throws ApplicationException
	 */
	public String saveFunctionAcl()throws ApplicationException{
		bs.saveFunctionAcl(roleid, functionid);
		Map info = (Map)this.getSession().getAttribute("userinfo");
		String type = info.get("type").toString();	
		String croleid=info.get("roleid").toString();
		if("0".equals(type)){
			croleid=null;
		}
		acl=bs.findFunctionJSON(roleid,croleid);
		return "forwardinitSysFunction";
	}
	
	public ISysAclBS getBs() {
		return bs;
	}

	public void setBs(ISysAclBS bs) {
		this.bs = bs;
	}

	public List getRoleList() {
		return roleList;
	}

	public void setRoleList(List roleList) {
		this.roleList = roleList;
	}
	public String getRoleid() {
		return roleid;
	}

	public void setRoleid(String roleid) {
		this.roleid = roleid;
	}
	public String getAcl() {
		return acl;
	}
	public void setAcl(String acl) {
		this.acl = acl;
	}
	public String[] getFunctionid() {
		return functionid;
	}
	public void setFunctionid(String[] functionid) {
		this.functionid = functionid;
	}
	@Override
	public Object getModel() {
		// TODO Auto-generated method stub
		return null;
	}
}
